package coreservlets;

import javax.faces.bean.*;

@ManagedBean
public class Controller {
	private DataBase db;
	@ManagedProperty(value="#{user}")
	private User user;

	public User getUser() {
		if (user == null){
			user = new User();
		}
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
	
	
	public String login() {

		user = getDb().login(user);
		if (user==null){
			return ("fail");
		}
		return ("success");

	}

	private DataBase getDb() {
		if (db == null){
			db = new DataBase();
		}
		return db;
	}

	
}
